import dao.CheckItemDao;
import dao.PatientDao;
import dao.impl.CheckItemDaoImpl;
import dao.impl.PatientDaoImpl;
import utils.ConnectionUtil;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.Scanner;

/**
 * @projectName: Hospital
 * @package: PACKAGE_NAME
 * @className: Test6
 * @author: 翟
 * @date: 2025/4/1 4:12
 */

public class Test6 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        Connection conn = null;
        System.out.println("用户登录");
        System.out.println("请输入身份证号码：");
        String identityNum = input.nextLine();
        System.out.println("请输入密码：");
        String password = input.nextLine();
        try {
            conn = ConnectionUtil.getConnection();
            PatientDao patientDao = new PatientDaoImpl(conn);
            if (patientDao.getPatientByIdentityNumAndPassword(identityNum , password) > 0){
                System.out.println("登录成功！！！");
                CheckItemDao checkItemDao = new CheckItemDaoImpl(conn);
                checkItemDao.getAll().forEach(System.out::println);
            }else{
                System.out.println("账号或密码错误！！！");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            ConnectionUtil.closeALL(null , null , conn);
        }
    }
}
